import 'dart:async';

import 'package:flutter/services.dart';

class TencentCos {
  static const MethodChannel _channel =
  const MethodChannel('tencent_cos');

  static Future<String> get platformVersion async {
    final String version = await _channel.invokeMethod('getPlatformVersion');
    return version;
  }

  static Future initCosServer(final String appID, final String bucket, final String region, final String signUrl, final String cookie) async {
    final int ret = await _channel.invokeMethod("initCosServer", {
      "appID": appID,
      "bucket": bucket,
      "region": region,
      "signUrl": signUrl,
      "cookie": cookie
    });
    return ret;
  }

  static Future<String> upload(final String localPath, final String cosPath) async {
    final String url = await _channel.invokeMethod("upload", {
      "localPath": localPath,
      "cosPath": cosPath
    });
    print("cos:" + url);
    return url;
  }
}
